@import url('./nv-variables.css');

:root {
    --nv-bg-main: #0a0a0c;
    --nv-brand-primary: #2596ff;     
    --nv-brand-muted: #69b7ff;       
    --nv-brand-light: #c8e4ff;       
    --nv-brand-glow: rgba(124, 77, 255, 0.15); 
    --nv-brand-dark: #234b78;
    --nv-text-primary: rgba(255, 255, 255, 0.92);
    --nv-text-muted: rgba(255, 255, 255, 0.65);
    --nv-border-soft: rgba(255, 255, 255, 0.06);
    --nv-border-blue: rgba(77, 160, 255, 0.2);
    
    --nv-ease-fluid: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* ==========================================
   1. Base Story Layout & Typography
   ========================================== */
.story {
    max-width: 42rem;
    margin: 0 auto;
    padding: 100px 24px;
    color: var(--text-color);
    font-size: 1.125rem;
    line-height: 1.8;
    letter-spacing: 0.02em;
    text-align: left;
    word-break: break-word;
    will-change: opacity;
    animation: textReveal 1s cubic-bezier(0.2, 0, 0.2, 1) forwards;
}

.story p {
    margin-bottom: 1.8rem; 
    font-weight: 400;
}

.story strong {
    color: #d4e9ff !important;
    font-weight: 500;
}

html.light-mode .story strong {
    color: #2c476c !important;
}

.story em {
    color: var(--nv-text-muted);
    font-style: italic;
}

html.light-mode .story em {
    color: rgba(0, 0, 0, 0.6);
}

.story mark {
    padding: 0.1rem 0.3rem;
    color: var(--nv-brand-muted);
    background: rgba(124, 77, 255, 0.12);
    border-radius: 4px;
    font-weight: 500;
}

/* ==========================================
   2. Headings (.title-h1, .title-h2)
   ========================================== */
.title-h1, 
.title-h2 {
    position: relative;
    margin-top: 4rem;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 550;
    letter-spacing: -0.01em;
}

.title-h1 { font-size: 1.7rem !important; }
.title-h2 { font-size: 1.4rem !important; }

.title-h1::before, 
.title-h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.1rem;
    background: #c8e4ff;
    border-radius: 2px;
    box-shadow: 0 0 8px #c8e4ff;
}

html.light-mode .title-h1 { color: #234b78; }
html.light-mode .title-h2 { color: #234b78; }

html.light-mode .title-h1::before,
html.light-mode .title-h2::before {
    background: #2c476c;
    box-shadow: none;
}

/* ==========================================
   3. Lists & Interactive Elements
   ========================================== */
.story ul, 
.story ol {
    margin: 0 0 2rem 1.2rem;
    padding: 0;
    color: var(--nv-text-primary);
}

.story li {
    margin-bottom: 0.6rem;
    padding-left: 0.2rem;
}

.story ul li::marker {
    color: var(--nv-brand-light);
}

html.light-mode .story ul li::marker {
    color: var(--nv-brand-dark);
}

.story input[type="checkbox"] {
    margin-right: 10px;
    accent-color: var(--nv-brand-primary);
    cursor: pointer;
}

html.light-mode .story ul, 
html.light-mode .story ol {
    color: rgba(0, 0, 0, 1);
}

.story a {
    color: var(--nv-brand-muted);
    text-decoration: none;
    position: relative;
    transition: color 0.3s ease;
}

.story a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--nv-border-blue);
    transform: scaleX(0.8);
    transform-origin: bottom left;
    transition: transform 0.3s ease, background-color 0.3s ease;
}

.story a:hover {
    color: #ffffff;
}

.story a:hover::after {
    transform: scaleX(1);
    background-color: var(--nv-brand-primary);
}

html.light-mode .story a {
    color: black;
}

html.light-mode .story a::after {
    background-color: rgba(88, 88, 88, 0.35);
}

html.light-mode .story a:hover {
    color: black;
}

html.light-mode .story a:hover::after {
    background-color: var(--nv-brand-primary);
}

/* ==========================================
   4. Blocks & Dividers (hr, blockquote)
   ========================================== */
.story hr {
    max-width: 42rem;
    margin: 48px auto;
    border: none;
    border-top: 1px solid rgba(224, 224, 224, 0.2);
}

html.light-mode .story hr {
    border-top: 1px solid rgba(0, 0, 0, 0.2);
}

.story blockquote {
    margin: 2.5rem 0;
    padding: 1.2rem 1.8rem;
    color: var(--nv-text-muted);
    background: rgba(255, 255, 255, 0.02);
    border-left: 2px solid var(--nv-brand-primary);
    border-radius: 2px 8px 8px 2px;
    font-size: 0.95rem;
    line-height: 1.7;
    box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.02);
}

html.light-mode .story blockquote {
    background: rgba(0, 0, 0, 0.02);
    color: rgba(0, 0, 0);
    border-left: 2px solid var(--nv-brand-dark);
    box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.1) 20px 0 0 rgba(0, 0, 0, 0.2);
    
}

.story blockquote p {
    margin: 0;
}

/* ==========================================
   5. Media Elements & Captions
   ========================================== */
.story img {
    display: block;
    max-width: 100%;
    height: 50vh;
    max-height: 68vh;
    width: auto;
    margin: 3rem auto;
    object-fit: contain;
    border: 1px solid var(--nv-border-soft);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    will-change: transform;
    transition: transform 0.5s var(--nv-ease-fluid), box-shadow 0.5s var(--nv-ease-fluid);
}

html.light-mode .story img {
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08);
}

.story img:hover {
    transform: translateY(-4px) scale(1.015);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6), 0 0 30px var(--nv-brand-glow);
    cursor: zoom-in;
}

html.light-mode .story img:hover {
    transform: scale(1.015);
    box-shadow: 0 24px 50px rgba(0, 0, 0, 0.18);
}

.story .img-caption {
    display: block;
    margin-top: 0.8rem;
    margin-bottom: 3.5rem;
    color: rgba(255, 255, 255, 0.45);
    text-align: center;
    font-size: 0.85rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

html.light-mode .story .img-caption {
    color: rgba(0, 0, 0, 0.5);
}

/* ==========================================
   6. TOC System
   ========================================== */
.toc-container {
    position: fixed;
    top: 50%; 
    right: 0;
    transform: translateY(-50%);
    
    width: 150px; 

    max-height: 60vh;
    height: auto; 
    
    overflow-y: auto; 
    overflow-x: hidden;
    
    padding: 24px 24px 24px 0; 
    z-index: 1000;
    
    background: rgba(255, 255, 255, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    border: 1px solid rgba(255, 255, 255, 0);
    border-radius: 20px 0 0 20px;
    box-shadow: none;
    
    transition: background 0.4s var(--nv-ease-fluid),
                backdrop-filter 0.4s var(--nv-ease-fluid),
                border 0.4s var(--nv-ease-fluid),
                box-shadow 0.4s var(--nv-ease-fluid),
                transform 0.4s var(--nv-ease-fluid);
}

.toc-container:hover {
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(24px) saturate(1.2);
    -webkit-backdrop-filter: blur(24px) saturate(1.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: -10px 25px 50px rgba(0, 0, 0, 0.3), 
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    
    transform: translateY(-50%) translateX(0); 
}

.toc-container::-webkit-scrollbar {
    width: 3px; 
}
.toc-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1); 
    border-radius: 2px;
}
.toc-container:hover::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2); 
}

.toc-title {
    font-weight: 600;
    color: var(--nv-text-primary);
    margin-bottom: 20px;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    padding-left: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

html.light-mode .toc-title {
    color: rgba(0, 0, 0, 0.9);
}
.toc-container:hover .toc-title {
    opacity: 0.4;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 15px; 
    align-items: flex-end; 
}

.toc-item {
    display: flex;
    flex-direction: row-reverse; 
    align-items: center;
    text-decoration: none;
    cursor: pointer;
    width: 100%;
    justify-content: flex-start;
    margin-right: 0 !important; 
}

html.light-mode .toc-item {
    color: rgba(0, 0, 0, 0.9);
}

html.light-mode .toc-text {
    color: rgba(0, 0, 0, 0.6);
}

html.light-mode .toc-item.active .toc-text,
html.light-mode .toc-item:hover .toc-text {
    color: rgba(0, 0, 0, 1) !important;
}

.toc-item.indent-h1 .toc-line { --base-width: 24px; width: 24px; }
.toc-item.indent-h2 .toc-line { --base-width: 12px; width: 12px; }
.toc-item.indent-h3 .toc-line { --base-width: 8px; width: 8px; }
.toc-item.indent-h4 .toc-line { --base-width: 4px; width: 4px; }

.toc-line {
    height: 2px;
    background-color: rgba(255, 255, 255, 0.2); 
    border-radius: 1px;
    flex-shrink: 0;
    margin-left: 14px; 
    
    transition: width 0.3s var(--nv-ease-fluid), 
                background-color 0.3s var(--nv-ease-fluid),
                box-shadow 0.3s var(--nv-ease-fluid);
}

.toc-text {
    color: var(--nv-text-muted);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    text-align: right;
    
    opacity: 0;
    transform: translateX(6px);
    transition: opacity 0.3s var(--nv-ease-fluid), 
                transform 0.3s var(--nv-ease-fluid);
}

.toc-container:hover .toc-text {
    opacity: 0.5;
    transform: translateX(0);
}

.toc-item:hover .toc-text,
.toc-item.active .toc-text {
    opacity: 1 !important;
    color: #ffffff;
}

.toc-container:hover .toc-line {
    background-color: rgba(255, 255, 255, 0.4);
}

.toc-item:hover .toc-line,
.toc-item.active .toc-line {
    width: 32px !important; 
    background-color: var(--nv-brand-light) !important;
    box-shadow: 0 0 8px var(--nv-brand-light);
}

html.light-mode .toc-container:hover {
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(0, 0, 0, 0.05);
}
html.light-mode .toc-line { 
    background-color: rgba(0, 0, 0, 0.2); 
}
html.light-mode .toc-container:hover .toc-line { 
    background-color: rgba(0, 0, 0, 0.4); 
}
html.light-mode .toc-item.active .toc-line,
html.light-mode .toc-item:hover .toc-line { 
    background-color: var(--nv-brand-dark) !important; 
    box-shadow: none; 
}

@media (max-width: 900px) {
    .toc-container { display: none; }
}
